/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.unesp.ia.gridsolver.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Pardal
 */
@Entity
@Table(name = "aluno", catalog = "cursos", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Aluno.findAll", query = "SELECT a FROM Aluno a"),
    @NamedQuery(name = "Aluno.findByIdAluno", query = "SELECT a FROM Aluno a WHERE a.idAluno = :idAluno"),
    @NamedQuery(name = "Aluno.findByNome", query = "SELECT a FROM Aluno a WHERE a.nome = :nome"),
    @NamedQuery(name = "Aluno.findBySemestre", query = "SELECT a FROM Aluno a WHERE a.semestre = :semestre")})
public class Aluno implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idAluno", nullable = false)
    private Integer idAluno;
    @Size(max = 45)
    @Column(name = "Nome", length = 45)
    private String nome;
    @Column(name = "Semestre")
    private Integer semestre;
    @JoinTable(name = "aluno_has_materia", joinColumns = {
        @JoinColumn(name = "Aluno", referencedColumnName = "idAluno", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "Materia", referencedColumnName = "idMateria", nullable = false)})
    @ManyToMany
    private List<Materia> materiaList;
    @JoinTable(name = "aluno_has_curso", joinColumns = {
        @JoinColumn(name = "Aluno", referencedColumnName = "idAluno", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "Curso", referencedColumnName = "idCurso", nullable = false)})
    @ManyToMany
    private List<Curso> cursoList;

    public Aluno() {
    }

    public Aluno(Integer idAluno) {
        this.idAluno = idAluno;
    }

    public Integer getIdAluno() {
        return idAluno;
    }

    public void setIdAluno(Integer idAluno) {
        this.idAluno = idAluno;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Integer getSemestre() {
        return semestre;
    }

    public void setSemestre(Integer semestre) {
        this.semestre = semestre;
    }

    @XmlTransient
    public List<Materia> getMateriaList() {
        return materiaList;
    }

    public void setMateriaList(List<Materia> materiaList) {
        this.materiaList = materiaList;
    }

    @XmlTransient
    public List<Curso> getCursoList() {
        return cursoList;
    }

    public void setCursoList(List<Curso> cursoList) {
        this.cursoList = cursoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAluno != null ? idAluno.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Aluno)) {
            return false;
        }
        Aluno other = (Aluno) object;
        if ((this.idAluno == null && other.idAluno != null) || (this.idAluno != null && !this.idAluno.equals(other.idAluno))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.unesp.ia.gridsolver.entity.Aluno[ idAluno=" + idAluno + " ]";
    }
    
}
